import Vue from 'vue'
import App from './App.vue'
import Header from '@/components/Header/Header.vue'
import Footer from '@/components/Footer/Footer.vue'
import TypeNav from '@/components/TypeNav'
import '@/assets/reset.css'
import router from '@/router'
import store from '@/store'

Vue.config.productionTip = false

//设置全局组件
Vue.component(Header.name, Header)
Vue.component(Footer.name, Footer)
Vue.component(TypeNav.name, TypeNav)

//引入swiper依赖  npm i swiper@5 vue-awesome-swiper@4
import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
//引入swiper css样式
import 'swiper/css/swiper.min.css'
//swiper全局注册
Vue.component('Swiper', Swiper)
Vue.component('SwiperSlide', SwiperSlide)

//mock模拟请求引入
import '@/mock/mockServer'

//防止typeNav多次请求方式二:
//请求typeNav全局数据
store.dispatch("getCategoryList");
//请求banner
store.dispatch("getMockBanner");
//请求floor
store.dispatch("getMockFloor");

// 分页器全局组件
import pagination from '@/components/Pagination'
Vue.component(pagination.name, pagination)

//调用导航守卫封装文件
import '@/permisstion'

//将api全部添加到Vue的原型上
import * as http from '@/api'

//引入element ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);


//引入图片懒加载  引入之后会有  v-lazy 全局指令
import VueLazyload from 'vue-lazyload'
// 引入loding图
import loading from '@/assets/1.gif';
// 引入替补图片
import error from '@/assets/2.png'
// 参数二为配置对象 
Vue.use(VueLazyload, {
  preLoad: 2,//预加载时间
  loading,
  error
})

//引入vee表单验证
import '@/util/VeeValidate'



new Vue({
  // 调用路由
  router,
  store,
  beforeMount() {
    //全局事件总线定义
    // this.prototype.$bus = this
    this.__proto__.$bus = this
    Vue.prototype.$http = http
  },
  render: h => h(App)
}).$mount('#app')
